<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.java.service.*,java.util.*,com.java.model.UserSession,com.java.util.*,java.text.SimpleDateFormat"%>
<jsp:include page="../common/header.jsp"></jsp:include>
<%
UserSession usersession = (UserSession)session.getAttribute("user");
//String ent_id 			= (String)session.getAttribute("ent_id");

String connGroup 	= "";
String user_id 		= "";
if(usersession!=null){
	connGroup 	= CmmUtil.nvl(usersession.getConnGroup(),"0");
	user_id 	= CmmUtil.nvl(usersession.getUser_id(),"");
}

System.out.println("connGroup======>"+connGroup);
System.out.println("user_id======>"+user_id);

/*
String present_Year = String.valueOf(GregorianCalendar.getInstance().get(Calendar.YEAR));
//GregorianCalendar에서 1월 return 값이 0이므로 Month에는  1을 더해주어야 함
String present_Month = String.valueOf(GregorianCalendar.getInstance().get(Calendar.MONTH)+1); 
String present_Date = String.valueOf(GregorianCalendar.getInstance().get(Calendar.DATE));

if(present_Month.length() == 1){
	present_Month = "0" + present_Month; //01월,02월 ..... 09월
}

GregorianCalendar g = new GregorianCalendar();
g.add(Calendar.MONTH, 0);

String befor_Month = String.valueOf(g.get(Calendar.MONTH));

if(befor_Month.length() == 1){
	befor_Month = "0" + befor_Month; //01월,02월 ..... 09월
}

if(present_Date.length() == 1){
	present_Date = "0" + present_Date; //01일,02일 ..... 09일
}

//start_dt,close_dt,selected_year,selected_month 의 값에 받아오는 인자가 없을 경우 default로 현재 시간을 Setting
String start_dt 		= CmmUtil.nvl(request.getParameter("start_dt"),present_Year + befor_Month + present_Date);
String close_dt 		= CmmUtil.nvl(request.getParameter("close_dt"),present_Year + present_Month + present_Date);
*/

Calendar now = Calendar.getInstance();
String year     = String.valueOf(now.get(Calendar.YEAR));
String month    = String.valueOf(now.get(Calendar.MONTH)+1);
String curDay   = String.valueOf(now.get(Calendar.DATE));

if(month.length() == 1){
	month = 0 + month;
}

if(curDay.length() == 1){
	curDay = 0 + curDay;
}

now.add(Calendar.MONTH,-1);

String b_year     = String.valueOf(now.get(Calendar.YEAR));
String b_month    = String.valueOf(now.get(Calendar.MONTH)+1);
String b_curDay   = String.valueOf(now.get(Calendar.DATE));

if(b_month.length() == 1){
	b_month = 0 + b_month;
}

if(b_curDay.length() == 1){
	b_curDay = 0 + b_curDay;
}

String start_dt = CmmUtil.nvl(request.getParameter("start_dt"),b_year + b_month + b_curDay);
String close_dt = CmmUtil.nvl(request.getParameter("close_dt"),year + month + curDay);

HashMap map_cnt = new HashMap();
HashMap map1_cnt = null;
HashMap map1_cnt2 = null;
ArrayList list_cnt = new ArrayList();	
CommonDaoService commonservice_cnt = new CommonDaoService("Com0204lp01Dao_cnt");
map_cnt.put("connGroup",connGroup);
map_cnt.put("user_id",user_id);	
map_cnt.put("start_dt",start_dt);	
map_cnt.put("close_dt",close_dt);		
list_cnt = (ArrayList)commonservice_cnt.commonDaoMethod(map_cnt);	
System.out.println(list_cnt);


String edu_cnt = "0";
String poi_cnt = "0";
String mis_conn_dt = "0";
String poorly_cnt = "0";
String recommend_ave_rate = "0";
String final_prog_ave_rate = "0";

for(int i=0; i<list_cnt.size(); i++){
	map1_cnt 			= (HashMap)list_cnt.get(i);  
	
	edu_cnt =  CmmUtil.nvl((String)map1_cnt.get("s_cate_cnt"),"0");
	poi_cnt = CmmUtil.nvl((String)map1_cnt.get("s_poi_cd_cnt"),"0");
	
	recommend_ave_rate = CmmUtil.nvl((String)map1_cnt.get("recommend_rate"),"0");
	final_prog_ave_rate = CmmUtil.nvl((String)map1_cnt.get("final_prog_rate"),"0");
	
	mis_conn_dt = CmmUtil.nvl((String)map1_cnt.get("conn_mis"),"0");
	poorly_cnt = CmmUtil.nvl((String)map1_cnt.get("stu_mis"),"0");	
}


%>
<body>
	<table width="100%"  border="0" cellpadding="0" cellspacing="0">
         <tr>
        	<td>
            	<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="main_table4">
                  <tr>
                    <td class="table_th">학습인원</td>
                    <td colspan="2"><%=edu_cnt %>명</td>
                    <td class="table_th">수강과정</td>
                    <td colspan="2"><%=poi_cnt %> 과정</td>
                  </tr>
                  <tr>
                    <td class="table_th">평균 진도 율</td>
                    <td colspan="2"><%=final_prog_ave_rate%>%</td>
                    <td class="table_th">권장 진도 율</td>
                    <td colspan="2"><%=recommend_ave_rate%>%</td>
                  </tr>
                  <tr>
                    <td class="table_th">진도 부진 자</td>
                    <td><%=poorly_cnt %>명</td>
                    <td><a href="javascript:" onclick="window.open('/jsp/pop/stu_state_pop.jsp?start_dt=<%=start_dt %>&close_dt=<%=close_dt %>&gubun=poorly','stu_state1','width=810,height=500,scrollbars=yes')"><img src="/images/hrd_main_BTN9.gif" alt="" border="0"/></a></td>
                    <td class="table_th">미 접속 자</td>
                    <td><%=mis_conn_dt %>명</td>
                    <td> <a href="javascript:" onclick="window.open('/jsp/pop/stu_state_pop.jsp?start_dt=<%=start_dt %>&close_dt=<%=close_dt %>&gubun=mis','stu_state1','width=810,height=500,scrollbars=yes')"><img src="/images/hrd_main_BTN9.gif" alt="" border="0"/></a></td>
                  </tr>
                </table>            
              </td>
        </tr>
        </table>
</body>
</html>